package pres.lnk.learn.designpattern.l_flyweight;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author lnk
 * @Date 2018/4/9
 */
public class ShapeFactory {
    private static final Map<String, Circle> circleMap = new HashMap<>();

    public static Circle getCircle(String color){
        Circle circle = circleMap.get(color);
        if(circle == null){
            circle = new Circle(color);
            circleMap.put(color, circle);
            System.out.println("Creating circle of color : " + color);
        }
        return circle;
    }
}
